1. Field of Invention
The present invention relates generally to computer implemented compilers and libraries for high-level programming languages and their associated run-time environments, and in particular to a method, apparatus, and program storage device for supporting improved record processing protocols for COBOL SORT and MERGE functions using input and output procedures in an object program.
2. Description of Related Art
A compiler is a computer program that translates a source program into an equivalent object program. The source language is typically a high level language like COBOL, and the object language is the assembly language or machine language of some computer. The translation of the source program into the object program occurs at compile times, and the actual execution of the object program occurs at run-time.
The compiler must perform an analysis of the source program. Then it must perform a synthesis of the object program wherein it first decomposes the source program into its basic parts, and then builds equivalent object programs from those parts. As a source program is analyzed, information is obtained from declarations, and procedural statements, such as loops, file system statements, and function calls. This includes the SORT and MERGE statements available in COBOL. Typically, these function calls are stored in object libraries that are linked and/or bound to the object program at run-time.
Some high-level languages, such as COBOL, require the specification of input and output procedures for the SORT and MERGE functions within the source program, which input and output procedures are then called by the SORT and MERGE functions within the object library. However, this creates problems when the input or the output procedure is invoked while the SORT or MERGE functions are active in the stack.
There is considerable overhead involved in invoking the SORT or MERGE function, and then having the SORT or MERGE function invoke the input or output procedures for each record. As a result, there is a significant amount of overhead for each record being passed to or from the SORT or MERGE functions.
Further, because the program which executed the SORT statement also contains the input and/or output procedures, this results in a "callback" situation. That is: a SORT statement results in an invocation of the sort function, which, in turn, invokes the input and/or output procedures in the same program. This makes the support of language semantics related to the access to resources (such as variables, files and procedures) to be within the program difficult since the input and/or output procedures are in the same program, but are in different execution stack frames.
Thus, there is a need in the art for optimized and improved record processing protocols for SORT and MERGE functions with input and/or output procedures.